Skip to content

fix(id-web): validate ordered_list start in parseDOM (#2005) - #4078

Merged
dezren39 merged 1 commit into
mainfrom
queue/5069-2005-ordered-list-start
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/5069-2005-ordered-list-start

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #2005 (task 5069).

Problem

ordered_list parseDOM read the <ol start> attribute with bare Number(), so pasted HTML could produce order values the markdown codec cannot represent (it reads order as u64): abc → NaN, 2.5 → fraction, 0x10 → 16, empty → 0, -3 → negative. On save those silently renumbered the list from 1.

Change

  • pkgs/id/web/src/editor.ts: new exported parseOrderedListStart — preserves only a plain non-negative decimal integer within safe-integer range (0 included); malformed, fractional, negative, hex/scientific, empty, or unsafe values fall back to 1 with no reinterpretation. parseDOM now uses it.
  • Scope kept to the packet: the task-list parser branch and image width/height parsing are untouched.

Tests

  • pkgs/id/web/src/editor.test.ts: unit + parseDOM getAttrs cases — abc, 2.5, 0x10, 1e3, empty, -3, 9007199254740993 → 1; 5, 0, 42 → preserved; absent attribute → 1.
  • Laptop: bunx vitest run src/editor.test.ts — 85/85 pass.
  • bunx tsc --noEmit shows exactly 1 error before and after this change, pre-existing in src/image-upload.test.ts (unrelated file).

🤖 Queue worker (repo-worker-code), task 5069.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Replace the bare Number() on the <ol start> attribute with
parseOrderedListStart: only a plain non-negative decimal integer
within safe-integer range is preserved (0 included); malformed,
fractional, negative, hex/scientific, empty, or unsafe values fall
back to 1 instead of being reinterpreted, so pasted lists no longer
silently renumber on save through the u64 markdown codec.

Tests: unit + parseDOM getAttrs cases for abc, 2.5, 0x10, 1e3, empty,
-3, 9007199254740993 (fallback 1) and 5, 0, 42 (preserved); editor
suite 85/85 pass on the laptop.
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 23:50
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46f7cdc8-a4c8-41fd-8beb-d50d653fe522
Commits

Reviewing files that changed from the base of the PR and between 74a872a and cbb749b.

Files selected for processing: 2
  • pkgs/id/web/src/editor.test.ts
  • pkgs/id/web/src/editor.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T23:51:45.292390Z cbb749b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id(web/editor): ordered_list parseDOM bare Number() lets NaN/fractional start through — pasted lists silently renumber from 1 on save

1 participant